#include "Wander.h"
#include "Agent.h"
#include "SteeringOutput.h"
#include "Timer.h"
#include "MathUtility.h"

namespace Engine
{
	void Wander::Update(SteeringOutput* output)
	{
		output->linear = m_parent->GetRotAsVector();
		output->linear *= m_parent->GetMaxSpeed();

		//
		// ---> Uncomment for simple wander
		//
		//output->angular = RandomBinomial(1.5f) * m_parent->GetMaxAngularVel();
		//
		// ---> delegated to face for simple wander
		//Face::Update(output);

		//
		// ---> smooth wander
		//
		float dt = TheTimer::Instance()->GetDT();
		const float speed = m_parent ->GetMaxSpeed() * dt;

		wander = ScalarRandom(wander, speed, -1, +1);
		output->angular = wander;
	}
}